package com.lingjtx.common.influx.factory;

import com.lingjtx.common.influx.client.InfluxSession;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;

public class InfluxMapperFactoryBean<T> implements FactoryBean<T> {

    private final Class<T> mapperInterface;

    @Autowired
    private InfluxSession influxSession;

    public InfluxMapperFactoryBean(Class<T> mapperInterface) {
        this.mapperInterface = mapperInterface;
    }

    @Override
    public T getObject() {
        return influxSession.getMapper(mapperInterface);
    }

    @Override
    public Class<?> getObjectType() {
        return mapperInterface;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}